<?php
/**
 * Addshift Function
 *
 * Add a new shift
 *
 * @author Max Sibbald <maxsibbald@gmail.com>
 */
include_once 'UTerrorcode.php';
include_once 'UTcheckAuth.php';
include_once 'UTDBGlobal.php';

/**
 * @param $authUser string
 * @param $authUserPass string
 * @param $arrayOfData string
 * @return array
 */
function addShift($authUser, $authUserPass, $arrayOfData)
{
	global $dbaddress;
    global $dbuser;
    global $dbpassword;
    global $dbdatabasename;
	
      if (checkAuthentication($authUser, $authUserPass) != true){
      	return array(ErrorCode::authFailRead);	
      }

      $conn=mysql_connect($dbaddress,$dbuser,$dbpassword,$dbdatabasename);
      if(!$conn)
      {
            die('Could not connect: ' . mysql_error());
            return array(ErrorCode::sysError);
      }

      $sql = "INSERT INTO RoleDate (roleID, empID, dateID, startTime, endTime, shiftStatus) VALUES ('".$arrayOfData['roleID']."','".$arrayOfData['empID']."','".$arrayOfData['dateID']."','".$arrayOfData['startTime']."','".$arrayOfData['endTime']."','".$arrayOfData['shiftStatus']."');";
      if (mysql_query($conn, $sql)){
            mysql_close($conn);
            return array(ErrorCode::successUpdate);
      } else {
            mysql_close($conn);
            return array(ErrorCode::failDelete);
      }
}

?>